package demo.practice.tree.depth;

import java.util.List;

class Node {
    public int val;
    public List<Node> children;

    public Node() {
    }

    public Node(int _val) {
        val = _val;
    }

    public Node(int _val, List<Node> _children) {
        val = _val;
        children = _children;
    }
}

public class P559 {


    public int maxDepth(Node root) {
        if (root == null)
            return 0;

        if (root.children.size() > 0) {
            int hc=0;
            for (Node ch: root.children
                 ) {
                hc= Math.max(hc,maxDepth(ch));
            }
//            root.children.forEach(i->{
//                hc=Math.max()
//            });
//            List<Integer> hs = new ArrayList<>();
//            root.children.forEach(i -> {
//                hs.add(maxDepth(i));
//            });
//
//            Collections.sort(hs);
            return hc+1;
        } else {
            return 1;
        }
    }
}
